package pers.lx.crm.dao.info;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import pers.lx.crm.entiy.info.CustomerDO;
import pers.lx.crm.entiy.info.CustomerInfoDO;

import java.util.List;

/**
 * Created by lx on 2017/3/7.
 */
@Repository
public interface CustomerDao {

    @Insert("insert into customer(name,template_id,create_date,update_date)values(#{name},#{templateId},#{createDate},#{updateDate})")
    public void insertCutomer(CustomerDO customerDO) ;

    @Select("select* from customer")
    public List<CustomerDO> selectCustomerListPage(CustomerDO customerDO) ;

    @Select("select customer.name,customer.create_date,customer.update_date,customer.template_id,template.name from customer,template where customer.id=#{id} and customer.template_id=template.id")
    public CustomerDO selectCustomer(CustomerDO customerDO) ;

    @Update("update customer set name=#{name},template_id=#{templateId},update_date=#{updateDate}")
    public void updateCustomer(CustomerDO customerDO) ;

    @Delete("delete from customer where id=#{id}")
    public void deleteCustomer(CustomerDO customerDO) ;

    @Select("select* from customer_info where customer_id=#{customerId}")
    public List<CustomerInfoDO> selectCustomerInfo(int customerId) ;

    @Insert("insert into customer_info(customer_id,tag_label_id,value)values(#{customerId},#{tagLabelId},#{value})")
    public void insertCustomerInfo(CustomerInfoDO customerInfoDO) ;

    @Delete("delete from customer_info where customer_id=#{customerId}")
    public void deleteCustomerInfo(int customerId) ;

}
